﻿
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/js/jquery.min.js"></script>
    <script src="~/js/jquery.form.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#subBtn").click(function () {
                if ($("#Method").val() == "APP") {
                    $.ajax({
                        type: "POST",
                        url: "/Home/ApiTestSubmit", //用与处理ajax的地址及函数
                        data: $("#form1").formSerialize(),
                        success: function(result) {
                            $("#data").html(result);
                        }
                    });
                } else {
                    $.ajax({
                        type: "POST",
                        url: $("#url").val(), //用与处理ajax的地址及函数
                        data: $("#parmer").val(),
                        dataType:"json",
                        success: function (result) {
                            $("#data").html(JSON.stringify(result));
                        }
                    });
                }
            });
        });
    </script>
</head>
<body>
<form method="post" id="form1">
    <table>
        <tr>
            <td>
                API接口地址
            </td>
            <td>
            <input type="text" name="url" id="url" style="width: 400px" placeholder="请输入API接口地址,以http://开头" value="http://localhost:8952/api/home/post" />
        </tr>
        <tr>
            <td>
                模拟类型
            </td>
            <td>
                <select name="Method" id="Method">
                    <option value="APP">APP</option>
                    <option value="H5">H5</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                参数(json)
            </td>
            <td>
                <textarea name="parmer" id="parmer" style="width: 400px; height: 200px;">{
"id":"0bda62b4-a178-46e0-b7c6-541e91eb138b",
"names":["123","123","123"],
"myChildOnes":[{"names":"aaa"},{"names":"bbbb"},{"names":"ccc"}],
"myChildTwo":{"names":"aaa"},
"age":1,
"sex":false
}</textarea>
            </td>
        </tr>
        <tr>
            <td>
                返回结果
            </td>
            <td>
                <xmp id="data"></xmp>
            </td>
        </tr>
        <tr>
            <td>
                操作
            </td>
            <td>
                <input type="button" id="subBtn" value="提交" />
            </td>
        </tr>
    </table>
</form>
</body>
</html>